﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KC.Presentation.SmokingQuitter
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private List<TimeSpan> Lozenges;
        DateTime LozengeStarted;

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Start Lozenge")
            {
                if (LozengeStarted < DateTime.Today)
                    Lozenges.Clear();

                button1.Text = "Stop Lozenge";
                LozengeStarted = DateTime.Now;
                textBox1.Text += DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + ": Lozenge Started\r\n";
            }
            else
            {
                button1.Text = "Start Lozenge";
                TimeSpan LozengeSpan = DateTime.Now - LozengeStarted;
                Lozenges.Add(LozengeSpan);
                textBox1.Text += DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + ": Lozenge Stopped. Duration: " + LozengeSpan.ToString() + "\r\n";
                textBox1.Text += "That makes " + Lozenges.Count.ToString() + " lozenges today.\r\n";

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Lozenges = new List<TimeSpan>();
        }
    }
}
